require("../../UIManager/UISoundManager.js");
cc.Class({
    extends: cc.Component,
    properties: {
        _type: null,
        _playMode: null
    },
    onLoad: function () {
        Global.notificationCenter.on(Global.eventName.UPDATE_ROOMINFO_SUCCESSED, this.updateRoomList.bind(this), this);
        Global.notificationCenter.on(Global.eventName.MSG_DO_QUICK_START, this.doQuickStart.bind(this), this);
    },
    start: function () {
    },
    doQuickStart: function (e) {
        e && (this._type = e.type, this._playMode = e.playMode, this._roomId = e.roomId,
            Global.SetGameId(e.gameId), Global.msgHandler.requestRoomList(e.playMode, e.gameId),
            console.log("QuickStartPersistManager doQuickStart data :", e));
    },
    updateRoomList: function () {
        if (this._type && this._playMode) {
            console.log("updateRoomList this._roomId :", this._roomId), Global.roomInfoModel.setPlayModel(this._playMode);
            var e = this._roomId || Global.roomInfoModel.getRecommendRoomId();
            if (e < 0) {
                cc.error("QuickStartPersistManager updateRoomList roomId<0");
                var t = {
                    text: "金币不足，快去分享获取金币吧！",
                    cancelSp: Global.spriteAtlas.getGoInviteSpf(),
                    cancelText: "去邀请",
                    cancelCallback: function () {
                        Global.UIPopupManager.addPopup("PopupPanel/Panel_InviteFri", function (e) {
                        });
                    },
                    closeCallback: function () {
                        console.log("closeCallback");
                    },
                    needConfirmBtn: !1
                };
                Global.UIPopupManager.alert(t);
            } else {
                Global.roomInfoModel.setRoomId(e);
                var n = Global.roomInfoModel.getPlayModel();
                Global.msgHandler.requestQuickStart(n, e), this._type = null, this._playMode = null;
            }
        } else console.error("updateRoomList this._type this._playMode:", this._type, this._playMode);
    },
    onDestroy: function () {
        Global.notificationCenter.offAll(this);
    }
})
